Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
    ''' <summary>
    ''' Controller class for PlayersInStats
    ''' </summary>
		<System.ComponentModel.DataObject()> Public Partial Class PlayersInStatsController
    
        ' Preload our schema..
        Dim thisSchemaLoad As PlayersInStats = New PlayersInStats()
        Private strUserName As String = String.Empty
        Protected ReadOnly Property UserName() As String
            Get
				If strUserName.Length = 0 Then
		        
    				If Not System.Web.HttpContext.Current Is Nothing Then
						strUserName = System.Web.HttpContext.Current.User.Identity.Name
					Else
		        		strUserName = System.Threading.Thread.CurrentPrincipal.Identity.Name
					End If
					Return strUserName
				End If
				Return strUserName
			End Get
        End Property
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchAll() As PlayersInStatsCollection
        
            Dim coll As PlayersInStatsCollection = New PlayersInStatsCollection()
            Dim qry As Query = New Query(PlayersInStats.Schema)
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
            
        End Function
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByID(ByVal Id As Object) As PlayersInStatsCollection 
        
            Dim coll As PlayersInStatsCollection = New PlayersInStatsCollection().Where("id", Id).Load()
            Return coll
        
        End Function
        
        <DataObjectMethod(DataObjectMethodType.Select, True)> Public Function FetchByQuery(ByVal qry As SubSonic.Query) As PlayersInStatsCollection 
        
            Dim coll As PlayersInStatsCollection = New PlayersInStatsCollection()
            coll.LoadAndCloseReader(qry.ExecuteReader())
            Return coll
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, True)> Public Function Delete(ByVal Id As Object) as Boolean
        
            Return (PlayersInStats.Delete(Id) = 1)
        
        End Function
        <DataObjectMethod(DataObjectMethodType.Delete, False)> Public Function Destroy(ByVal Id As Object) as Boolean
        
            Return (PlayersInStats.Destroy(Id) = 1)
        
        End Function
        
    	
	    ''' <summary>
	    ''' Inserts a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Insert, True)> Public Sub Insert(ByVal PlayerID As Integer,ByVal Gameid As Integer,ByVal Catches As Nullable(Of Integer),ByVal Runs As Nullable(Of Integer),ByVal Saves As Nullable(Of Integer),ByVal Injured As Nullable(Of Boolean))
	   
		    Dim item As PlayersInStats = New PlayersInStats()
		    
            item.PlayerID = PlayerID
            
            item.Gameid = Gameid
            
            item.Catches = Catches
            
            item.Runs = Runs
            
            item.Saves = Saves
            
            item.Injured = Injured
            
	    
		    item.Save(UserName)
	   
	   End Sub
    	
	    ''' <summary>
	    ''' Updates a record, can be used with the Object Data Source
	    ''' </summary>
        <DataObjectMethod(DataObjectMethodType.Update, True)> Public Sub Update(ByVal Id As Integer,ByVal PlayerID As Integer,ByVal Gameid As Integer,ByVal Catches As Nullable(Of Integer),ByVal Runs As Nullable(Of Integer),ByVal Saves As Nullable(Of Integer),ByVal Injured As Nullable(Of Boolean))
	    
		    Dim item As PlayersInStats = New PlayersInStats()
		    
				item.Id = Id
				
				item.PlayerID = PlayerID
				
				item.Gameid = Gameid
				
				item.Catches = Catches
				
				item.Runs = Runs
				
				item.Saves = Saves
				
				item.Injured = Injured
				
		    item.MarkOld()
		    item.Save(UserName)
	    
	    End Sub
    End Class
End Namespace
